package com.fakesmoker.project.service.impl.inner;/**
 * @program: springboot-init-old-master
 * @author: lcy
 * @create: 2025-02-19 16:04
 */

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fakesmoker.apicommon.model.entity.InterfaceInfo;
import com.fakesmoker.apicommon.service.InnerInterfaceInfoService;
import com.fakesmoker.project.common.ErrorCode;
import com.fakesmoker.project.exception.BusinessException;
import com.fakesmoker.project.mapper.InterfaceInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 2025/2/19,
 */

@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {
    @Override
    public void validInterfaceInfo(InterfaceInfo interfaceInfo, boolean add) {

    }

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;

    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if (url == null || StringUtils.isAnyBlank(url)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为空");
        }
        if (method == null || StringUtils.isAnyBlank(method)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为空");
        }

        QueryWrapper<InterfaceInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("url", url);
        queryWrapper.eq("method", method);
        return interfaceInfoMapper.selectOne(queryWrapper);
    }
}
